import moment from 'moment';

export default class WeatherTimeUtils {
    /**
     * 201708251500->15:00
     */
    static getWeatherTime(time) {
        return moment(time, "YYYYMMDDHHmm").format('HH:mm');
    }

    /**
     * 20170825->0825
     */
    static getWeatherDate(time) {
        return moment(time, "YYYYMMDD").format('MM-DD');
    }

    /**
     * 根据日期计算星期几
     * 格式 20191224
     */
    static weekDay(date) {
        var dt = new Date(date.substring(0, 4), date.substring(4, 6) - 1, date.substring(6));
        var weekDay = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
        return weekDay[dt.getDay()];
    }
}
